#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Taotie Ren

#name = [1,2,3,4,5,6,7,8]

id_db = {
    12345678901234:{
        'name':"Tom",
        'age':24,
        'addr':"CN"
    },
    12345678922234: {
        'name': "Tom",
        'age': 24,
        'addr': "CN"
    },
    12345678933234: {
        'name': "Tom",
        'age': 24,
        'addr': "CN"
    },

}
print(id_db)

print(id_db[12345678901234])
id_db[12345678901234]['name'] = "Tim"
id_db[12345678901234]['qq_of_wife'] = 123467
print(id_db[12345678901234])
id_db[12345678901234].pop("addr")
print(id_db[12345678901234])
v = id_db.get(12345678901234)
print(v)

dict2 = {
    'name': "Wang",
    12345678933234: {
        'name': "Tom",
        'age': 24,
        'addr': "CN"
    },
}

id_db.update(dict2)
print(id_db)
print(id_db.values())
print(id_db.keys())
12345678901234 in id_db
id_db.setdefault(12345678901234,"emmmmm")#取一个值，不存在就添加默认值
print(id_db)
print(id_db.fromkeys([1,2,3,4,5,6,7],'ddddd'))
print(id_db.popitem())#随机删除
print(id_db)

for k,v in id_db.items():#效率低，因为要进行一个dict to list 的转换过程
    print(k,v)

for key in id_db:#效率高
    print(key,id_db[key])